﻿<%@ Page Title="" Language="C#" MasterPageFile="~/BackMaster2.Master" AutoEventWireup="true" CodeBehind="User_Show.aspx.cs" Inherits="BackStage.User_Show" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script src="/BootstrapSouce/js/jquery.min.js"></script>
   <%--   <script src="/BootstrapSouce/js/bootstrap.min.js"></script>
    <link href="/BootstrapSouce/css/bootstrap.min.css" rel="stylesheet" />--%>
    <script src="BootstrapSouce/js/Command.js"></script>
   <%--   <script src="/BootstrapSouce/js/bootstrap.min.js"></script>
    <link href="/BootstrapSouce/css/bootstrap.min.css" rel="stylesheet" />--%>
    <%--<script src="/Command.js"></script>--%>
    <script>
        $(function () {
            $("#sousuotable").hide();
            Page(1);
        })
        var counttt = 0;
        //分页显示及分页
        function Page(indexs) {
            $.ajax({
                type: "post",
                url: "/Hand/User_Page.ashx",
                data: {
                    username: $("#name").val(),//用户名
                    userreadname: $("#zhenshiname").val(),//用户真实姓名
                    pageindex: indexs,//第几页
                    pagesize: 8
                },
                success: function (datas) {
                    $("#tables").empty();
                    var da = JSON.parse(datas);
                    var ts = '<tr   ><td>ID</td><td>用户名</td><td>真实姓名</td><td>性别</td><td>年龄</td><td>手机号</td><td>月收入</td><td>操作</td></tr>';
                    for (var q = 0; q < da.Data.length; q++) {
                        ts += '<tr><td>' + da.Data[q].UserId + '</td><td><a onclick="xiangqing(' + da.Data[q].UserId + ')" data-toggle="modal" data-target="#myModal"   href="#"> ' + da.Data[q].UserName + '</a></td><td>' + da.Data[q].UserrRealName + '</td><td>' + da.Data[q].UserSex + '</td><td>' + da.Data[q].UserAge + '</td><td>' + da.Data[q].UserPhone + '</td><td>' + da.Data[q].MIncome + '</td><td><a onclick="huiyuanupgate(' + da.Data[q].UserId + ')"  data-toggle="modal" data-target="#s" href="#">修改</a></td></tr>';
                    }
                    $("#tables").html(ts);
                    //  alert(da.PageCount);
                    counttt = da.PageCount;
                   // var tas = "<tr style='background-color:#eddede';><td><input id='sousuo' onclick='sousuoget()' type='button' value='筛选/搜索' />&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<span> 共<label id='sums'>" + da.PageCount + "</label>  页 &nbsp&nbsp&nbsp&nbsp当前第 <label id='index'>" + da.PageIndex + "</label> 页&nbsp&nbsp&nbsp&nbsp <a onclick='Page(1)'>首页</a>&nbsp&nbsp&nbsp&nbsp";
                    //判断当前页是否为1，如果不是那就减一如果是那就直接定到第一页
                    //if (da.PageIndex <= 1) {
                    //    tas += ("<a  onclick='Page(1)'  >上一页</a>&nbsp&nbsp&nbsp&nbsp");
                    //}
                    //else {
                    //    tas += ("<a  onclick='Page(" + (da.PageIndex - 1) + ")'  >上一页</a>&nbsp&nbsp&nbsp&nbsp");
                    //}
                    ////判断是否为最后一页。如果不是那就加一如果是那就直接定到最后一页
                    //if (da.PageIndex >= da.PageCount) {
                    //    tas += "<a  onclick='Page(" + (da.PageCount) + ")' >下一页</a>&nbsp&nbsp&nbsp&nbsp";
                    //} else {
                    //    tas += "<a  onclick='Page(" + (da.PageIndex + 1) + ")' >下一页</a>&nbsp&nbsp&nbsp&nbsp";
                    //}
                    //tas += " <a onclick='Page(" + da.PageCount + ")'>尾页</a>&nbsp&nbsp&nbsp&nbsp";
                    ////跳转页
                    //tas += "转到<input id='pageas' style='width:50px' type='text' /><input id='Button1' type='button'  onclick='tiaozhuan()'  value='确定' /></span></td> </tr>";
                    var pager = "";
                    pager += "<li style='float:right'><a> 当前第 " + da.PageIndex + " 页</a><a> 共" + da.PageCount + "页  </a><a>转到<input type='number' id='pageas' />页<input type='button' class='ben btn-primary' onclick='tiaozhuan()'  min='1'  value='确定'></a></li>";
                    pager += "<li> <a href='#' onclick='Page(1)'>首页</a></li>";
                    //判断当前页是否为1，如果不是那就减一如果是那就直接定到第一页
                    if (da.PageIndex <= 1) {
                        pager += ("<li><a href='#'  onclick='Page(1)'  >上一页</a></li>");
                    }
                    else {
                        pager += ("<li><a href='#'  onclick='Page(" + (da.PageIndex - 1) + ")'  >上一页</a></li>");
                    }
                    //判断是否为最后一页。如果不是那就加一如果是那就直接定到最后一页
                    if (da.PageIndex >= da.PageCount) {
                        pager += "<li><a  href='#' onclick='Page(" + (da.PageCount) + ")' >下一页</a></li>";
                    } else {
                        pager += "<li><a  href='#' onclick='Page(" + (da.PageIndex + 1) + ")' >下一页</a></li>";
                    }
                    pager += " <li><a  href='#' onclick='Page(" + (da.PageCount) + ")'>尾页</a></li>";
                    pager += "<li style='float:left'><a href='#' id='sousuo' onclick='sousuoget()'  >筛选</a><li>";
                    $("#pager").html(pager);
                    //$("#tass").html(tas);
                }
            })
        };
        //跳转分页
        function tiaozhuan() {
            var idd = $("#pageas").val();
            if (idd > counttt) {
                alert("您输入的页数到达极限！为您跳转到尾页");
                Page(counttt);
            } else {
                Page(idd);
            }
        };
        //会员详情
        function xiangqing(id) {
            //会员账户资金
            $.getJSON("/Hand/MemProperty_Show.ashx", { id: id }, function (data) {
                $("#account").html(data.AccountTotal);
                $("#frozen").html(data.FrozenTotal);
                $("#availablebalance").html(data.AvailableBalance);
                $("#incomesum").html(data.IncomeSum);
            })
            //会员信息
            $.getJSON("/Hand/User_Details.ashx", { id: id }, function (jsondata) {
                var readname = jsondata[0].UserrRealName;
                var name = jsondata[0].UserName;
                var carid = jsondata[0].IdCard;
                var sex = jsondata[0].UserSex;
                var email = jsondata[0].UserEmail;
                var phone = jsondata[0].UserPhone;
                var tel = jsondata[0].UserTel;
                var hunyin = jsondata[0].MaritalState;
                var adress = jsondata[0].UserrAddres;
                var age = jsondata[0].UserAge;
                $("#myModalLabel").html(readname + "的详细信息");
                $("#Label_name").html(name);//会员名
                $("#Label_carid").html(carid);//身份证号
                $("#Label_sex").html(sex);//性别
                $("#Label_email").html(email);//邮箱
                $("#Label_phone").html(phone);//手机号
                $("#Label_tel").html(tel);//电话号
                $("#Label_hunyin").html(hunyin);//婚姻状况
                $("#Label_adress").html(adress);//居住地
                $("#Label_readname").html(readname);//真实姓名
                $("#Label_age").html(age);//年龄
            });


        }
        //搜索
        function sousuoget() {
            $("#sousuotable").toggle();
            $("#name").val("");//用户名
            $("#zhenshiname").val("");//用户真实姓名
            Page(1);
        }
        //执行搜索
        function sousuogeting() {
            Page(1);
        }
        //会员修改
        function huiyuanupgate(id) {
            $.getJSON("/Hand/User_GetUpdate.ashx", { id: id }, function (data) {
                $("#upid").val(id);
                var img = data.HeadImage;//头像
                $("#upimg").val(img);
                var name = data.UserName;//用户名
                $("#upname").val(name);
                var pwd = data.UserPwd;//密码
                $("#uppwd").val(pwd);
                var carid = data.IdCard;//身份证
                $("#upcarid").val(carid);
                var sexs = data.UserSex;//性别
                //判断性别并给予赋值
                if (sexs == "男") {
                    document.getElementById("man").checked = true;
                } else {
                    document.getElementById("girl").checked = true;
                }
                var email = data.UserEmail;//邮箱
                $("#upemail").val(email);
                var phone = data.UserPhone;//手机号
                $("#upiphone").val(phone);
                var tel = data.UserTel;//电话
                $("#uptel").val(tel);
                var hunyin = data.MaritalState;//婚姻状况
                if (hunyin == "未婚") {
                    document.getElementById("weihun").checked = true;
                } else {
                    document.getElementById("yinhun").checked = true;
                }
                var yueshouru = data.MIncome;//月收入
                $("#upyuemoney").val(yueshouru);
                var jiguan = data.UserrPlaceOrigin;//籍贯
                $("#upjiguan").val(jiguan);
                var readname = data.UserrRealName;//真实姓名
                $("#upreadname").val(readname);
                var zhiye = data.UserrOccupation;//职业
                $("#upzhiye").val(zhiye);
                var age = data.UserAge;//年龄
                $("#upage").val(age);
                var xueli = data.UserEducation;//学历
                $("#upxueli").val(xueli);
                var xinyongedu = data.Creditlimit;//信用额度
                $("#upxinyongedu").val(xinyongedu);
                var huiyuanjibie = data.UserMemlevelId;//会员级别     下拉菜单
                $("#uphuiyuanjibie option[value='" + huiyuanjibie + "']").attr("selected", true);//给下拉框显示这条信息的对应值
                // $("#uphuiyuanjibie").val(huiyuanjibie); 
                var juzhudi = data.UserrAddres;//居住地址
                $("#upjuzhudi").val(juzhudi);
            });
        }
        //修改提交
        function upgets() {
            var sexs = "";
            if (document.getElementById("man").checked == true) {
                sexs = "1";
            } else {
                sexs = "0";
            }
            var hunyins = "";
            if (document.getElementById("yinhun").checked == true) {
                hunyins = "1";
            } else {
                hunyins = "0";
            }
            var selects = document.getElementById("uphuiyuanjibie").selectedIndex;

            $.ajax({
                type: "post",
                url: "/Hand/User_Update.ashx",
                data: {
                    id: $("#upid").val(),
                    img: $("#upimg").val(),//头像
                    name: $("#upname").val(),//用户名
                    carid: $("#upcarid").val(),//身份证
                    sex: sexs,//性别
                    email: $("#upemail").val(),//邮箱
                    phone: $("#upiphone").val(),//手机号
                    tel: $("#uptel").val(),//电话
                    hunyin: hunyins,//婚姻状况
                    yueshouru: $("#upyuemoney").val(),//月收入
                    jiguan: $("#upjiguan").val(),//籍贯
                    readname: $("#upreadname").val(),//真实姓名
                    zhiye: $("#upzhiye").val(),//职业
                    age: $("#upage").val(),//年龄
                    xueli: $("#upxueli").val(),//学历
                    xinyongedu: $("#upxinyongedu").val(),//信用额度
                    huiyuanjibie: selects + 1,//会员级别     下拉菜单
                    // $("#uphuiyuanjibie").val(huiyuanjibie); 
                    juzhudi: $("#upjuzhudi").val()//居住地址
                },
                success: function (date) {
                    if (date > 0) {
                        //alert("修改成功");
                        location.reload();
                    } else {
                        alert("修改失败");
                    }
                }
            });
        }
    </script>
    <%-- 搜索框 --%>
    <table id="sousuotable" style="margin-top: 50px;">
        <tr>
            <td>用户名：</td>
            <td>
                <input id="name" type="text" /></td>
            <td>真实姓名：</td>
            <td>
                <input id="zhenshiname" type="text" /></td>
            <td>&nbsp 
                <input id="Button1" type="button" class="btn btn-primary" onclick="sousuogeting()" value="搜索" /></td>
        </tr>
    </table>
    <%-- 会员列表显示框 --%>
    <table class="table table-hover" id="tables">
    </table>
    <%-- 分页控件显示 --%>
    <table style="width: 1700px;" id="tass" class="table table-hover">
    </table>
    <div><ul class="pager" id="pager">

       </ul></div>
    
    <%-- 会员详情 --%>
    <div class="modal fade" id="myModal" style="display:none" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel"></h4>
                </div>
                <div id="xiangqing_huiyuan" class="modal-body">

                    <%-- 模态框标头显示 --%>
                    <ul id="myTab" class="nav nav-tabs">
                        <li class="active">
                            <a href="#home" data-toggle="tab">会员资料
                            </a>
                        </li>
                        <li><a href="#ios" data-toggle="tab">账户资金</a></li>

                    </ul>
                    <%-- 模态框内容显示 --%>
                    <div id="myTabContent" class="tab-content">
                        <%-- 会员详情 --%>
                        <div class="tab-pane fade in active" id="home">

                            <table class="table">
                                <tr>
                                    <td style="width: 100px;">会员名：</td>
                                    <td>
                                        <label id="Label_name"></label>
                                    </td>
                                    <td>身份证号：</td>
                                    <td>
                                        <label id="Label_carid"></label>
                                    </td>
                                </tr>
                                <tr>
                                    <td>性别：</td>
                                    <td>
                                        <label id="Label_sex"></label>
                                    </td>
                                    <td>邮箱：</td>
                                    <td>
                                        <label id="Label_email"></label>
                                    </td>
                                </tr>
                                <tr>
                                    <td>手机号：</td>
                                    <td>
                                        <label id="Label_phone"></label>
                                    </td>
                                    <td>电话号：</td>
                                    <td>
                                        <label id="Label_tel"></label>
                                    </td>
                                </tr>
                                <tr>
                                    <td>婚姻状况：</td>
                                    <td>
                                        <label id="Label_hunyin"></label>
                                    </td>
                                    <td>居住地：</td>
                                    <td>
                                        <label id="Label_adress"></label>
                                    </td>
                                </tr>
                                <tr>
                                    <td>真实姓名：</td>
                                    <td>
                                        <label id="Label_readname"></label>
                                    </td>
                                    <td>年龄：</td>
                                    <td>
                                        <label id="Label_age"></label>
                                    </td>
                                </tr>
                            </table>
                        </div>
                        <%-- 资金状况 --%>
                        <div class="tab-pane fade" id="ios">
                            <table class="table">
                                <tr>
                                    <td style="width: 100px;">账户总额：</td>
                                    <td>
                                        <label id="account"></label>
                                    </td>
                                    <td style="width: 100px;">冻结总额：</td>
                                    <td>
                                        <label id="frozen"></label>
                                    </td>
                                </tr>
                                <tr>
                                    <td>可用余额：</td>
                                    <td>
                                        <label id="availablebalance"></label>
                                    </td>

                                    <td>累计净赚收益:</td>
                                    <td>
                                        <label id="incomesum"></label>
                                    </td>
                                </tr>

                            </table>
                        </div>
                    </div>
                </div>
                <%-- 模态框的尾部 --%>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                    <%--  <button type="button" class="btn btn-primary">
                        提交更改
                    </button>--%>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal -->
    </div>
    <%-- 会员修改 --%>
    <!-- 模态框（Modal） -->
    <div class="modal fade" id="s" style="display:none" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabe">会员信息修改
                    </h4>
                </div>
                <div class="modal-body">
                    <table class="table table-hover">
                        <tr>
                            <td>头像：</td>
                            <td>
                                <input id="upimg" type="text" /><input id="upid" type="hidden" /></td>
                            <td>用户名：</td>
                            <td>
                                <input id="upname" type="text" /></td>
                        </tr>
                        <tr>
                            <td>身份证号：</td>
                            <td>
                                <input id="upcarid" type="text" /></td>
                            <td>性别：</td>
                            <td>
                                <input id="girl" name="sex" checked="checked" type="radio" />女<input id="man" name="sex" type="radio" />男
                            </td>
                        </tr>
                        <tr>
                            <td>邮箱：</td>
                            <td>
                                <input id="upemail" type="text" /></td>
                            <td>手机号：</td>
                            <td>
                                <input id="upiphone" type="text" /></td>
                        </tr>
                        <tr>
                            <td>电话号：</td>
                            <td>
                                <input id="uptel" type="text" /></td>
                            <td>婚姻状况：</td>
                            <td>
                                <input id="weihun" name="hunyin" checked="checked" type="radio" />未婚<input id="yinhun" name="hunyin" type="radio" />已婚
                            </td>
                        </tr>
                        <tr>
                            <td>月收入：</td>
                            <td>
                                <input id="upyuemoney" type="text" /></td>
                            <td>籍贯：</td>
                            <td>
                                <input id="upjiguan" type="text" /></td>
                        </tr>
                        <tr>
                            <td>真实姓名：</td>
                            <td>
                                <input id="upreadname" type="text" /></td>
                            <td>职业：</td>
                            <td>
                                <input id="upzhiye" type="text" /></td>
                        </tr>
                        <tr>
                            <td>年龄：</td>
                            <td>
                                <input id="upage" type="text" /></td>
                            <td>学历：</td>
                            <td>
                                <input id="upxueli" type="text" /></td>
                        </tr>
                        <tr>
                            <td>信用额度：</td>
                            <td>
                                <input id="upxinyongedu" type="text" /></td>
                            <td>会员级别：</td>
                            <td>
                                <select id="uphuiyuanjibie">
                                    <option value="1">一级</option>
                                    <option value="2">二级</option>
                                    <option value="3">三级</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td>居住地：</td>
                            <td>
                                <input id="upjuzhudi" type="text" /></td>

                        </tr>
                    </table>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                    <button type="button" onclick="upgets()" class="btn btn-primary">
                        提交更改
                    </button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal -->
    </div>
</asp:Content>


